<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
	<title>WiFi配置</title>
	<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp"%>
	<style type="text/css">
		.listinfo p{
			padding: 10px 5px;
			color: #666;
		}
	</style>
</head>
<body>
	<div class="container">
		<div style="text-align:center;padding-top:20px;">
			<img style="width:100px;" src="<%=basePath%>/image/oss/iot/wifilogo.png">
		</div>
		<div class="listinfo">
			<p>1. 请给设备上电</p>
			<p>2. 确认手机已连接WiFi网络</p>
			<p>3. 长按"配置按键"，直至WiFi模块指示灯闪烁</p>
			<p>4. 点击开始配置</p>		
		</div>
		
		<div class="width100 m-auto" style="margin: 20px;margin-top: 70px;">
			<a class="weui-btn" style="background:#06be04;" href="javascript:" 
						id="networkbtn">开始配置</a>			
		</div>
	</div>
	<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	<script src="<%=basePath%>/lib/weixinLib/WeixinApi.js"></script>
</body>
<script type="text/javascript">

var noncestr =  "${noncestr}" ;
var timestamp = "${timestamp}" ;
var signature = "${signature}" ;

wx.config({
	debug : false, 	// 开启调试模式
	appId : "<%=ProConfig.WEIXIN.APP_ID%>", 
	timestamp : timestamp, // 必填，生成签名的时间戳
	nonceStr : noncestr, // 必填，生成签名的随机串
	signature : signature,// 必填，签名，见附录1
	jsApiList : [ 'checkJsApi', 'scanQRCode','configWXDeviceWiFi' ]
});

var flag = WeixinApi.openInWeixin();
if(!flag){
	// alert("请在微信浏览器中打开");
	$(".qrcode").hide();
}

$(function(){
	
	$("#networkbtn").click(function(){
		wx.invoke('configWXDeviceWiFi', {}, function(res){  
             var err_msg = res.err_msg;
             if(err_msg == 'configWXDeviceWiFi:ok') { 
            	 window.location.href = '<%=basePath%>/service/wiot/edevicescene'  ;
                 return;
             } else {
            	
             }
         });
	})
	
})



	
</script>
</html>